home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / CPrint.as < prev    next >
Text File  |  2007-11-08  |  9KB  |  247 lines

  1. class CPrint extends mx.core.UIObject
  2. {
  3.    var mFooter = "<span class=\"s_Header\">┬⌐ 2007 Copyright  Istituto della Enciclopedia Italiana fondata da Giovanni Treccani</span>";
  4.    var mHeader = "<span class=\"s_Header\">Enciclopedia Italiana di Scienze, Lettere ed Arti</span>";
  5.    var mTextFieldOverHeight = 4;
  6.    var mPrintIntervalId = 0;
  7.    var mTopMargin = 48;
  8.    var mImageLeftMargin = 16;
  9.    var mBottomMargin = 36;
  10.    var mPrintFontSize = 12;
  11.    var mPrintTextLeading = 5;
  12.    function CPrint()
  13.    {
  14.       super();
  15.       this._visible = false;
  16.       this.mPrinting = false;
  17.       this.doLater(this,"init");
  18.    }
  19.    function init(Void)
  20.    {
  21.       this.mShowAlert = true;
  22.       this.mPrinting = false;
  23.       this.mTextFieldOverHeight = 4;
  24.       this.txt_PrintHeader.html = true;
  25.       this.txt_PrintHeader.multiline = true;
  26.       this.txt_PrintHeader.embedFonts = _global.gUseEmbeddedFont;
  27.       this.txt_PrintHeader.styleSheet = _global.gStyleManager.GetPrintCSS();
  28.       this.txt_PrintTitle.html = true;
  29.       this.txt_PrintTitle.multiline = true;
  30.       this.txt_PrintTitle.embedFonts = _global.gUseEmbeddedFont;
  31.       this.txt_PrintTitle.styleSheet = _global.gStyleManager.GetPrintCSS();
  32.       this.txt_PrintBody.html = true;
  33.       this.txt_PrintBody.multiline = true;
  34.       this.txt_PrintBody.autoSize = false;
  35.       this.txt_PrintBody.embedFonts = _global.gUseEmbeddedFont;
  36.       this.txt_PrintBody.styleSheet = _global.gStyleManager.GetPrintCSS();
  37.       this.txt_PrintFooter.html = true;
  38.       this.txt_PrintFooter.multiline = true;
  39.       this.txt_PrintFooter.embedFonts = _global.gUseEmbeddedFont;
  40.       this.txt_PrintFooter.styleSheet = _global.gStyleManager.GetPrintCSS();
  41.       this.mPrintFontSize = 12;
  42.       this.mPrintTextLeading = 5;
  43.       this.mLineHeight = this.mPrintFontSize + this.mPrintTextLeading;
  44.       this.mPrintTextFormat = new TextFormat();
  45.       this.mPrintTextFormat.size = this.mPrintFontSize;
  46.       this.mPrintTextFormat.leading = this.mPrintTextLeading;
  47.       this.mPrintIntervalId = 0;
  48.    }
  49.    function PrintImage(inTitleHtml, inDidaHtml, inImageUrl)
  50.    {
  51.       this.txt_PrintHeader.htmlText = this.mHeader;
  52.       this.txt_PrintFooter.htmlText = this.mFooter;
  53.       this.txt_PrintTitle.htmlText = inTitleHtml;
  54.       this.txt_PrintBody.htmlText = inDidaHtml;
  55.       this.mc_PrintImage.__set__contentPath(inImageUrl);
  56.       this.mc_PrintImage._visible = true;
  57.       this.txt_PrintTitle._visible = true;
  58.       this.txt_PrintBody.scroll = 0;
  59.       this.mPrintIntervalId = setInterval(this,"doPrintImage",400);
  60.    }
  61.    function doPrintImage()
  62.    {
  63.       if(this.mc_PrintImage.__get__percentLoaded() < 100)
  64.       {
  65.          return undefined;
  66.       }
  67.       if(this.mPrintIntervalId)
  68.       {
  69.          clearInterval(this.mPrintIntervalId);
  70.       }
  71.       this.mPrintIntervalId = 0;
  72.       var _loc2_ = new PrintJob();
  73.       if(_loc2_.start() != true)
  74.       {
  75.          return undefined;
  76.       }
  77.       var _loc3_ = _loc2_.pageWidth;
  78.       var _loc4_ = _loc2_.pageHeight;
  79.       this.SetupHeaderFooter(_loc3_,_loc4_);
  80.       this.txt_PrintTitle._width = _loc3_;
  81.       this.txt_PrintTitle._height = this.txt_PrintTitle.textHeight + this.mTextFieldOverHeight;
  82.       this.txt_PrintTitle._x = 0;
  83.       var _loc8_ = Math.max(this.mTopMargin,this.txt_PrintHeader._height + 12);
  84.       this.txt_PrintTitle._y = _loc8_;
  85.       this.txt_PrintBody._width = _loc3_;
  86.       this.txt_PrintBody._height = this.txt_PrintBody.textHeight + this.mTextFieldOverHeight;
  87.       this.txt_PrintBody._x = 0;
  88.       var _loc10_ = Math.max(this.mBottomMargin,this.txt_PrintFooter._height + 12);
  89.       var _loc7_ = _loc4_ - _loc10_ - this.txt_PrintBody._height;
  90.       this.txt_PrintBody._y = _loc7_;
  91.       var _loc6_ = _loc8_ + this.txt_PrintTitle._height + 12;
  92.       var _loc11_ = _loc7_ - 12;
  93.       var _loc5_ = _loc11_ - _loc6_;
  94.       if(_loc5_ < 100)
  95.       {
  96.       }
  97.       this.mc_PrintImage._x = this.mImageLeftMargin;
  98.       this.mc_PrintImage._y = _loc6_;
  99.       this.mc_PrintImage.setSize(_loc3_ - 2 * this.mImageLeftMargin,_loc5_);
  100.       var _loc9_ = {xMin:0,xMax:_loc3_,yMin:0,yMax:_loc4_};
  101.       if(_loc2_.addPage(this,_loc9_))
  102.       {
  103.          _loc2_.send();
  104.       }
  105.       false;
  106.       _loc2_ = undefined;
  107.    }
  108.    function PrintHtml(inHeaderHtml, inHtml)
  109.    {
  110.       this.mShowAlert = true;
  111.       if(this.mPrinting == true)
  112.       {
  113.          return undefined;
  114.       }
  115.       if(this.mShowAlert == true)
  116.       {
  117.          _global.gAlert.ShowAlert("","Stampa in corso","EMPTY",10);
  118.          updateAfterEvent();
  119.       }
  120.       this.mHeaderHtml = inHeaderHtml;
  121.       this.mHtml = inHtml;
  122.       this.doLater(this,"DoPrintHtml_wait");
  123.    }
  124.    function DoPrintHtml_wait()
  125.    {
  126.       this.doLater(this,"DoPrintHtml");
  127.    }
  128.    function DoPrintHtml()
  129.    {
  130.       var _loc2_ = this.mHeaderHtml;
  131.       this.mHeaderHtml = "";
  132.       var _loc3_ = this.mHtml;
  133.       this.mHtml = "";
  134.       if(this.mPrintIntervalId)
  135.       {
  136.          clearInterval(this.mPrintIntervalId);
  137.       }
  138.       this.mPrintIntervalId = 0;
  139.       this.mc_PrintImage._visible = false;
  140.       if(_loc2_ == undefined)
  141.       {
  142.          _loc2_ = "";
  143.       }
  144.       this.txt_PrintHeader.htmlText = this.mHeader + "<br>" + _loc2_;
  145.       this.txt_PrintFooter.htmlText = this.mFooter;
  146.       if(_loc3_ == undefined)
  147.       {
  148.          _loc3_ = "";
  149.       }
  150.       this.txt_PrintTitle.htmlText = "";
  151.       this.txt_PrintTitle._visible = false;
  152.       this.txt_PrintBody.htmlText = _loc3_;
  153.       this.txt_PrintBody.setTextFormat(this.mPrintTextFormat);
  154.       this.txt_PrintBody.scroll = 0;
  155.       this.mPrintIntervalId = setInterval(this,"doPrint",500);
  156.    }
  157.    function doPrint()
  158.    {
  159.       if(this.mPrintIntervalId)
  160.       {
  161.          clearInterval(this.mPrintIntervalId);
  162.       }
  163.       this.mPrintIntervalId = 0;
  164.       var _loc5_ = new PrintJob();
  165.       if(_loc5_.start() != true)
  166.       {
  167.          if(this.mShowAlert)
  168.          {
  169.             _global.gAlert.Hide();
  170.          }
  171.          this.mPrinting = false;
  172.          return undefined;
  173.       }
  174.       var _loc10_ = _loc5_.pageWidth;
  175.       var _loc8_ = _loc5_.pageHeight;
  176.       this.SetupHeaderFooter(_loc10_,_loc8_);
  177.       this.txt_PrintTitle._visible = false;
  178.       var _loc9_ = Math.max(this.txt_PrintHeader._height,this.mTopMargin);
  179.       var _loc15_ = _loc8_ - Math.max(this.mBottomMargin,this.txt_PrintFooter._height + 12);
  180.       this.txt_PrintBody._width = _loc10_;
  181.       this.txt_PrintBody._height = Math.floor((_loc15_ - _loc9_) / this.mLineHeight) * this.mLineHeight;
  182.       this.txt_PrintBody._x = 0;
  183.       this.txt_PrintBody._y = _loc9_;
  184.       var _loc4_ = 0;
  185.       var _loc14_ = 0;
  186.       var _loc12_ = _loc5_.pageWidth - 20;
  187.       var _loc13_ = 0;
  188.       var _loc11_ = _loc8_;
  189.       var _loc6_ = {xMin:_loc14_,xMax:_loc12_,yMin:_loc13_,yMax:_loc11_};
  190.       if(_loc5_.addPage(this,_loc6_))
  191.       {
  192.          _loc4_ = _loc4_ + 1;
  193.       }
  194.       while(this.txt_PrintBody.bottomScroll < this.txt_PrintBody.maxscroll)
  195.       {
  196.          this.txt_PrintBody.scroll = this.txt_PrintBody.bottomScroll + 1;
  197.          if(_loc5_.addPage(this,_loc6_))
  198.          {
  199.             _loc4_ = _loc4_ + 1;
  200.          }
  201.       }
  202.       if(this.txt_PrintBody.scroll < this.txt_PrintBody.maxscroll)
  203.       {
  204.          var _loc7_ = "";
  205.          var _loc3_ = 0;
  206.          while(_loc3_ < this.txt_PrintBody.bottomScroll - this.txt_PrintBody.maxscroll + 10)
  207.          {
  208.             _loc7_ += "<br>";
  209.             _loc3_ = _loc3_ + 1;
  210.          }
  211.          this.txt_PrintBody.htmlText += _loc7_;
  212.          this.txt_PrintBody.scroll = this.txt_PrintBody.bottomScroll + 1;
  213.          if(_loc5_.addPage(this,_loc6_))
  214.          {
  215.             _loc4_ = _loc4_ + 1;
  216.          }
  217.       }
  218.       if(_loc4_ > 0)
  219.       {
  220.          _loc5_.send();
  221.       }
  222.       false;
  223.       _loc5_ = undefined;
  224.       this.txt_PrintBody.htmlText = "";
  225.       if(this.mShowAlert)
  226.       {
  227.          _global.gAlert.Hide();
  228.       }
  229.       this.mPrinting = false;
  230.    }
  231.    function SetupHeaderFooter(printWidth, printHeight)
  232.    {
  233.       this.mc_PrintBkg._width = printWidth;
  234.       this.mc_PrintBkg._height = printHeight;
  235.       this.mc_PrintBkg._x = this.mc_PrintBkg._y = 0;
  236.       this.txt_PrintHeader._width = printWidth;
  237.       this.txt_PrintHeader._x = this.txt_PrintHeader._y = 0;
  238.       this.txt_PrintFooter._width = printWidth;
  239.       this.txt_PrintFooter._height = this.txt_PrintFooter.textHeight + this.mTextFieldOverHeight;
  240.       this.txt_PrintFooter._x = 0;
  241.       this.txt_PrintFooter._y = printHeight - this.txt_PrintFooter._height;
  242.    }
  243.    function Destroy()
  244.    {
  245.    }
  246. }
  247.